package itcast.bos.base.service.imp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import itcast.bos.base.dao.FixedAreaResporitory;
import itcast.bos.base.service.IFixedAreaService;
import itcast.bos.domain.base.Area;
import itcast.bos.domain.base.Courier;
import itcast.bos.domain.base.FixedArea;

@Service
@Transactional
public class FixedAreaService implements IFixedAreaService {

	@Autowired
	private FixedAreaResporitory far;

	@Override
	public Page<FixedArea> findAll(Specification<FixedArea> sf, Pageable pageable) {
		return far.findAll(sf, pageable);
	}

	@Override
	public void save(FixedArea model) {
		far.save(model);
	}

	@Override
	public void doAcc(FixedArea model, Courier c) {
		// 先通过model查找到持久化对象，
		FixedArea fa = far.findOne(model.getId());
		fa.getCouriers().add(c);
	}

	@Override
	public FixedArea findOne(String faid) {

		return far.findOne(faid);
	}

	

}
